package cn.HuanG.login.service.impl;

import cn.HuanG.base.exception.BusinessException;
import cn.HuanG.login.domain.LoginInfo;
import cn.HuanG.login.mapper.EmpLoginMapper;
import cn.HuanG.login.service.IEmpLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmpLoginServiceImpl implements IEmpLoginService {
    @Autowired
    private EmpLoginMapper empLoginMapper;
    @Override
    public LoginInfo countByUsername(LoginInfo loginInfo) {
        //获取用户账户后去后台查询
        LoginInfo employee1 = empLoginMapper.countByUsername(loginInfo.getUsername());
    if (employee1==null){
        if (!employee1.getPassword().equals(loginInfo.getPassword())){
            throw new BusinessException("你个dsb，账号密码错了");
        }
        return employee1;
    }
        throw new BusinessException("小屁娃，快去注册");
    }
//        //将前端用户输入的数据加密
//        String md5 = MD5Utils.encrypByMd5(loginInfo.getPassword() + employee1.getSalt());
//        if (!md5.equals(loginInfo.getPassword())){
//            throw new BusinessException("你个dsb，账号密码错了");
//        }
//        return employee1;
//        }
}
